

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/IKKIS_LOGO.png">
  <link rel="icon" href="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/IKKIS_LOGO.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Ikki">
  <meta name="keywords" content="">
  
    <meta name="description" content="0到1搭建antd组件库">
<meta property="og:type" content="article">
<meta property="og:title" content="antd组件库搭建">
<meta property="og:url" content="http://81.68.132.127/2022/11/11/FrontEndEngineering/%E7%BB%84%E4%BB%B6%E5%BA%93%E6%90%AD%E5%BB%BA/index.html">
<meta property="og:site_name" content="IKKI">
<meta property="og:description" content="0到1搭建antd组件库">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/beijing/iTab-pk6y2p.jpeg">
<meta property="article:published_time" content="2022-11-11T14:14:05.000Z">
<meta property="article:modified_time" content="2022-11-11T14:16:07.898Z">
<meta property="article:author" content="Ikki">
<meta property="article:tag" content="组件库">
<meta property="article:tag" content="antd">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/beijing/iTab-pk6y2p.jpeg">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>antd组件库搭建 - IKKI</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="/fluid/css/fluid-extention.css">
<link rel="stylesheet" href="/fluid/css/nihao.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"81.68.132.127","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":3},"lazyload":{"enable":true,"loading_img":"https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 100vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Ikki-BUG制造者</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('http://image.ikki0603.cn') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="antd组件库搭建"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-11-11 22:14" pubdate>
          2022年11月11日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          7.5k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          63 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
        <div class="scroll-down-bar">
          <i class="iconfont icon-arrowdown"></i>
        </div>
      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">antd组件库搭建</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2022年11月11日 晚上
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="1-仓库搭建"><a href="#1-仓库搭建" class="headerlink" title="1.仓库搭建"></a>1.仓库搭建</h1><ol>
<li><p>项目初始化</p>
<figure class="highlight maxima"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-adsak4lacl5vox"></i><span>maxima</span><div class="collapse show" id="collapse-adsak4lacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs maxima"><span class="hljs-built_in">mkdir</span> antd-<span class="hljs-built_in">demo</span><br>cd antd-<span class="hljs-built_in">demo</span><br>pnpm init<br></code></pre></td></tr></table></div></figure></li>
<li><p>安装依赖</p>
<figure class="highlight sql"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-984i60lacl5vox"></i><span>sql</span><div class="collapse show" id="collapse-984i60lacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql">pnpm <span class="hljs-keyword">add</span> typescript <span class="hljs-keyword">rollup</span> gulp <span class="hljs-variable">@rollup</span><span class="hljs-operator">/</span>plugin<span class="hljs-operator">-</span>babel <span class="hljs-variable">@rollup</span><span class="hljs-operator">/</span>plugin<span class="hljs-operator">-</span>typescript <span class="hljs-variable">@babel</span><span class="hljs-operator">/</span>core <span class="hljs-variable">@babel</span><span class="hljs-operator">/</span>preset<span class="hljs-operator">-</span>env <span class="hljs-variable">@babel</span><span class="hljs-operator">/</span>preset<span class="hljs-operator">-</span>react <span class="hljs-variable">@babel</span><span class="hljs-operator">/</span>plugin<span class="hljs-operator">-</span>transform<span class="hljs-operator">-</span>runtime   <span class="hljs-operator">-</span>D <span class="hljs-comment">--save</span><br>pnpm <span class="hljs-keyword">add</span>  tslib <span class="hljs-variable">@babel</span><span class="hljs-operator">/</span>runtime  <span class="hljs-comment">--save -w</span><br></code></pre></td></tr></table></div></figure></li>
<li><p>创建packages文件夹和子文件夹<br><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/front-end-dngineering/ikki-2022-09-28-13-48-42.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload></p>
</li>
<li><p>packages的子文件夹中创建package.json文件夹</p>
<figure class="highlight applescript"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-qbxc5flacl5vox"></i><span>applescript</span><div class="collapse show" id="collapse-qbxc5flacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs applescript"><span class="hljs-comment">--&gt; package.json</span><br>&#123;<br>  <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;@study/style&quot;</span>, <span class="hljs-comment">#name以@study开头</span><br>  <span class="hljs-string">&quot;version&quot;</span>: <span class="hljs-string">&quot;1.0.0&quot;</span>,<br>  <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;&quot;</span>,<br>  <span class="hljs-string">&quot;main&quot;</span>: <span class="hljs-string">&quot;index.js&quot;</span>,<br>  <span class="hljs-string">&quot;scripts&quot;</span>: &#123;<br>    <span class="hljs-string">&quot;build&quot;</span>: <span class="hljs-string">&quot;gulp&quot;</span>  <span class="hljs-comment">#gulp打包工具</span><br>  &#125;,<br>  <span class="hljs-string">&quot;keywords&quot;</span>: [],<br>  <span class="hljs-string">&quot;author&quot;</span>: <span class="hljs-string">&quot;&quot;</span>,<br>  <span class="hljs-string">&quot;license&quot;</span>: <span class="hljs-string">&quot;ISC&quot;</span><br>&#125;<br><br></code></pre></td></tr></table></div></figure></li>
<li><p>根目录下创建pnpm-workspace.yaml文件</p>
<figure class="highlight ldif"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-vdp3jflacl5vox"></i><span>ldif</span><div class="collapse show" id="collapse-vdp3jflacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs ldif"><span class="hljs-literal">-</span>-&gt; pnpm-workspace.yaml<br><span class="hljs-attribute">packages</span>:<br>  <span class="hljs-comment"># all packages in direct subdirs of packages/ 包的直接子目录中的所有包</span><br>  - &#x27;packages/*&#x27;<br></code></pre></td></tr></table></div></figure></li>
<li><p>生成tsconfig.json文件</p>
<figure class="highlight ada"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-xalscblacl5vox"></i><span>ada</span><div class="collapse show" id="collapse-xalscblacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs ada">运行  tsc <span class="hljs-comment">--init</span><br><br><span class="hljs-comment">--&gt; tsconfig.json</span><br>&#123;<br>  <span class="hljs-string">&quot;include&quot;</span>: [<br>    <span class="hljs-string">&quot;packages/*/src&quot;</span><br>  ],<br>  <span class="hljs-string">&quot;exclude&quot;</span>: [<br>    <span class="hljs-string">&quot;esm&quot;</span>,<br>    <span class="hljs-string">&quot;cjs&quot;</span>,<br>    <span class="hljs-string">&quot;lib&quot;</span>,<br>    <span class="hljs-string">&quot;script&quot;</span>,<br>    <span class="hljs-string">&quot;node_modules&quot;</span><br>  ],<br>  <span class="hljs-string">&quot;compilerOptions&quot;</span>: &#123;<br>    <span class="hljs-string">&quot;target&quot;</span>: <span class="hljs-string">&quot;es2016&quot;</span>,                                 <br>    <span class="hljs-string">&quot;lib&quot;</span>: [<span class="hljs-string">&quot;esnext&quot;</span>,<span class="hljs-string">&quot;DOM&quot;</span>],                                        <br>    <span class="hljs-string">&quot;jsx&quot;</span>: <span class="hljs-string">&quot;react&quot;</span>,                               <br>    <span class="hljs-string">&quot;module&quot;</span>: <span class="hljs-string">&quot;ESNext&quot;</span>,                               <br>    <span class="hljs-string">&quot;moduleResolution&quot;</span>: <span class="hljs-string">&quot;node&quot;</span>,                                     <br>    <span class="hljs-string">&quot;esModuleInterop&quot;</span>: <span class="hljs-literal">true</span>,                            <br>    <span class="hljs-string">&quot;forceConsistentCasingInFileNames&quot;</span>: <span class="hljs-literal">true</span>,           <br>    <span class="hljs-string">&quot;strict&quot;</span>: <span class="hljs-literal">true</span>,                                      <br>    <span class="hljs-string">&quot;skipLibCheck&quot;</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-string">&quot;baseUrl&quot;</span>: <span class="hljs-string">&quot;./&quot;</span>,                                 <br>    <span class="hljs-string">&quot;paths&quot;</span>: &#123;<br>      <span class="hljs-string">&quot;@study/*&quot;</span>: [<br>        <span class="hljs-string">&quot;./packages/*/src&quot;</span><br>      ]<br>    &#125;                                                   <br>  &#125;<br>&#125;<br></code></pre></td></tr></table></div></figure></li>
</ol>
<h1 id="2-style仓库配置"><a href="#2-style仓库配置" class="headerlink" title="2.style仓库配置"></a>2.style仓库配置</h1><ol>
<li>style文件夹下创建tsconfig.json文件<figure class="highlight ada"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-f4iz7xlacl5vox"></i><span>ada</span><div class="collapse show" id="collapse-f4iz7xlacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><code class="hljs ada"><span class="hljs-comment">--&gt; tsconfig.json</span><br>&#123;<br>  <span class="hljs-string">&quot;include&quot;</span>: [<span class="hljs-string">&quot;./src&quot;</span>],<br>  <span class="hljs-string">&quot;exclude&quot;</span>: [<br>    <span class="hljs-string">&quot;node_modules&quot;</span>,<br>    <span class="hljs-string">&quot;lib&quot;</span>,<br>    <span class="hljs-string">&quot;esm&quot;</span>,<br>    <span class="hljs-string">&quot;cjs&quot;</span>,<br>    <span class="hljs-string">&quot;lib/**/*&quot;</span>,<br>    <span class="hljs-string">&quot;esm/**/*&quot;</span>,<br>    <span class="hljs-string">&quot;cjs/**/*&quot;</span>,<br>    <span class="hljs-string">&quot;scripts/**/*&quot;</span><br>  ],<br>  <span class="hljs-string">&quot;compilerOptions&quot;</span>: &#123;<br>    <span class="hljs-string">&quot;target&quot;</span>: <span class="hljs-string">&quot;ES2015&quot;</span>,<br>    <span class="hljs-string">&quot;lib&quot;</span>: [<span class="hljs-string">&quot;DOM&quot;</span>, <span class="hljs-string">&quot;ESNext&quot;</span>],<br>    <span class="hljs-string">&quot;module&quot;</span>: <span class="hljs-string">&quot;ESNext&quot;</span>,<br>    <span class="hljs-string">&quot;moduleResolution&quot;</span>: <span class="hljs-string">&quot;Node&quot;</span>,<br>    <span class="hljs-string">&quot;jsx&quot;</span>: <span class="hljs-string">&quot;react&quot;</span>,<br>    <span class="hljs-string">&quot;resolveJsonModule&quot;</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-string">&quot;esModuleInterop&quot;</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-string">&quot;skipLibCheck&quot;</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-string">&quot;noEmitOnError&quot;</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-string">&quot;baseUrl&quot;</span>: <span class="hljs-string">&quot;.&quot;</span>,<br>    <span class="hljs-string">&quot;rootDir&quot;</span>: <span class="hljs-string">&quot;src&quot;</span>,<br>    <span class="hljs-string">&quot;outDir&quot;</span>: <span class="hljs-string">&quot;lib&quot;</span>,<br>    <span class="hljs-string">&quot;declaration&quot;</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-string">&quot;declarationMap&quot;</span>: <span class="hljs-literal">false</span>,<br>    <span class="hljs-string">&quot;paths&quot;</span>: &#123;&#125;<br>  &#125;<br>&#125;<br></code></pre></td></tr></table></div></figure></li>
<li>style文件夹下创建gulpfile.js文件<figure class="highlight javascript"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-p1cdd0lacl5vox"></i><span>javascript</span><div class="collapse show" id="collapse-p1cdd0lacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><code class="hljs javascript">--&gt; gulpfile.<span class="hljs-property">js</span><br><br><br><span class="hljs-keyword">const</span> &#123; src,dest,parallel &#125; = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;gulp&#x27;</span>)<br><span class="hljs-keyword">const</span> gulpBabel = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;gulp-babel&#x27;</span>);<br><span class="hljs-keyword">const</span> gulpTs = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;gulp-typescript&#x27;</span>);<br><span class="hljs-keyword">const</span> less = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;gulp-less&#x27;</span>);<br><span class="hljs-keyword">const</span> &#123;getTSConfig,getBabelConfig&#125; = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;./scripts/shared&#x27;</span>);<br><br><span class="hljs-comment">//将src下的ts文件转换成js复制到cjs文件夹下</span><br><span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">compileToESM</span>(<span class="hljs-params"></span>)&#123;<br>	<span class="hljs-keyword">const</span> tsconfig = <span class="hljs-title function_">getTSConfig</span>()<br>	<span class="hljs-keyword">const</span> &#123; compilerOptions &#125; = tsconfig<br>	<span class="hljs-keyword">return</span> <span class="hljs-keyword">await</span> <span class="hljs-title function_">src</span>(<span class="hljs-string">&#x27;src/**/*.ts&#x27;</span>).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">gulpTs</span>(compilerOptions)).<span class="hljs-property">js</span>.<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">gulpBabel</span>(<span class="hljs-title function_">getBabelConfig</span>(<span class="hljs-literal">true</span>))).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;esm&#x27;</span>))<br>&#125;<br><br><span class="hljs-comment">//将src下的ts文件转换成js复制到cjs文件夹下</span><br><span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">compileToCJS</span>(<span class="hljs-params"></span>)&#123; <br>	<span class="hljs-keyword">const</span> tsconfig = <span class="hljs-title function_">getTSConfig</span>()<br>	<span class="hljs-keyword">const</span> &#123; compilerOptions &#125; = tsconfig<br>	<span class="hljs-keyword">return</span> <span class="hljs-keyword">await</span> <span class="hljs-title function_">src</span>(<span class="hljs-string">&#x27;src/**/*.ts&#x27;</span>).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">gulpTs</span>(compilerOptions)).<span class="hljs-property">js</span>.<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">gulpBabel</span>(<span class="hljs-title function_">getBabelConfig</span>(<span class="hljs-literal">false</span>))).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;cjs&#x27;</span>))<br>&#125;<br><br><span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">generateDts</span>(<span class="hljs-params"></span>)&#123; <br>	<span class="hljs-keyword">const</span> tsconfig = <span class="hljs-title function_">getTSConfig</span>()<br>	<span class="hljs-keyword">const</span> &#123; compilerOptions &#125; = tsconfig<br>	<span class="hljs-keyword">return</span> <span class="hljs-keyword">await</span> <span class="hljs-title function_">src</span>(<span class="hljs-string">&#x27;src/**/*.ts&#x27;</span>).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">gulpTs</span>(&#123;<br>		...compilerOptions,<br>		<span class="hljs-string">&quot;declaration&quot;</span>:<span class="hljs-literal">true</span>,<br>		<span class="hljs-string">&quot;emitDeclarationOnly&quot;</span>:<span class="hljs-literal">true</span>.<span class="hljs-property">valueOf</span><br>	&#125;)).<span class="hljs-property">dts</span>.<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;lib&#x27;</span>))<br>&#125;<br><br><span class="hljs-comment">//将src下的less文件和js文件复制到esm和cjs文件夹下</span><br><span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">copyAssets</span>(<span class="hljs-params"></span>)&#123; <br>	<span class="hljs-keyword">return</span> <span class="hljs-keyword">await</span> <span class="hljs-title function_">src</span>([<span class="hljs-string">&#x27;src/**/*.less&#x27;</span>, <span class="hljs-string">&#x27;src/**/*.js&#x27;</span>]).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;esm&#x27;</span>)).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;cjs&#x27;</span>))<br>&#125;<br><br><span class="hljs-comment">//将src下的less文件转换成css文件输出到esm和cjs文件夹下</span><br><span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">lessToCss</span>(<span class="hljs-params"></span>)&#123; <br>	<span class="hljs-keyword">return</span> <span class="hljs-keyword">await</span> <span class="hljs-title function_">src</span>(<span class="hljs-string">&#x27;src/index.less&#x27;</span>).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">less</span>(&#123;<br>		<span class="hljs-attr">javascriptEnabled</span>: <span class="hljs-literal">true</span><br>	&#125;)).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;esm&#x27;</span>)).<span class="hljs-title function_">pipe</span>(<span class="hljs-title function_">dest</span>(<span class="hljs-string">&#x27;cjs&#x27;</span>))<br>&#125;<br><br><span class="hljs-built_in">exports</span>.<span class="hljs-property">default</span> = <span class="hljs-title function_">parallel</span>( copyAssets,lessToCss,compileToESM, compileToCJS,generateDts)<br><br><br><br></code></pre></td></tr></table></div></figure></li>
<li>创建scripts文件夹和其子文件shared.js<figure class="highlight lua"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-lvhljolacl5vox"></i><span>lua</span><div class="collapse show" id="collapse-lvhljolacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><code class="hljs lua"><br>const <span class="hljs-built_in">path</span> = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;path&#x27;</span>);<br>const fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;fs-extra&#x27;</span>);<br><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">CWD</span><span class="hljs-params">()</span></span>&#123;<br>    <span class="hljs-keyword">return</span> process.cwd();<br>&#125;<br><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBabelConfig</span><span class="hljs-params">(isESM)</span></span>&#123;<br>    <span class="hljs-keyword">return</span> &#123;<br>        presets: [<br>            [<br>                <span class="hljs-string">&#x27;@babel/preset-env&#x27;</span>,<br>                &#123;<br>                  modules: isESM ? <span class="hljs-literal">false</span> : <span class="hljs-string">&#x27;commonjs&#x27;</span>,<br>                  targets: &#123;<br>                    browsers: [<span class="hljs-string">&#x27;&gt; 0.5%&#x27;</span>, <span class="hljs-string">&#x27;last 2 versions&#x27;</span>, <span class="hljs-string">&#x27;Firefox ESR&#x27;</span>, <span class="hljs-string">&#x27;IE 11&#x27;</span>, <span class="hljs-string">&#x27;not dead&#x27;</span>],<br>                  &#125;,<br>                &#125;,<br>            ],<br>        ],<br>        plugins: <span class="hljs-string">[[&#x27;@babel/plugin-transform-runtime&#x27;, &#123; corejs: 3 &#125;]]</span>,<br>    &#125;<br>&#125;<br>// 获取tsconfig.json文件中的compilerOptions<br><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getTSConfig</span><span class="hljs-params">(</span></span><br><span class="hljs-params"><span class="hljs-function">    tsconfigPath = path.join(CWD()</span></span>,<span class="hljs-string">&#x27;tsconfig.json&#x27;</span>),<br>    subConfig = &#123; compilerOptions:&#123;&#125; &#125; <br>)&#123;<br>    <span class="hljs-keyword">if</span>(fs.pathExistsSync(tsconfigPath))&#123;<br>        let <span class="hljs-built_in">config</span> = fs.readJSONSync(tsconfigPath);<br>        const &#123; compilerOptions &#125; = <span class="hljs-built_in">config</span><br>        const &#123; compilerOptions:subCompilerOptions &#125; = subConfig<br>        subConfig.compilerOptions = &#123;...compilerOptions,...subCompilerOptions&#125;<br>        <span class="hljs-built_in">config</span> = Object.assign(<span class="hljs-built_in">config</span>,subConfig);<br>        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">config</span>.extends)&#123;<br>            const extendsPath =  <span class="hljs-built_in">path</span>.join(<span class="hljs-built_in">path</span>.dirname(tsconfigPath),<span class="hljs-built_in">config</span>.extends)<br>            <span class="hljs-built_in">config</span> = getTSConfig(extendsPath,<span class="hljs-built_in">config</span>)<br>            delete <span class="hljs-built_in">config</span>.extends<br>        &#125;<br>        <span class="hljs-keyword">return</span> <span class="hljs-built_in">config</span><br>    &#125;<br>    <span class="hljs-keyword">return</span> subConfig;<br>&#125;<br><span class="hljs-built_in">module</span>.exports = &#123;<br>    getBabelConfig,<br>    getTSConfig<br>&#125;<br></code></pre></td></tr></table></div></figure></li>
</ol>
<ol start="4">
<li>可以运行<code>pnpm --filter @study/style run build</code> 来进行style文件夹的gulp打包<br><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/front-end-dngineering/ikki-2022-09-28-14-26-26.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload></li>
</ol>
<h1 id="3-util仓库搭建"><a href="#3-util仓库搭建" class="headerlink" title="3.util仓库搭建"></a>3.util仓库搭建</h1><ul>
<li>目录结构<br><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/front-end-dngineering/2022-11-06-22-02-48_8bbf4be2.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-11-06-22-02-48"></li>
</ul>
<ol>
<li>tsconfig.json<figure class="highlight json"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-mytfw3lacl5vox"></i><span>json</span><div class="collapse show" id="collapse-mytfw3lacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-punctuation">&#123;</span><br>  <span class="hljs-attr">&quot;include&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">&quot;./src&quot;</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;exclude&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><br>    <span class="hljs-string">&quot;node_modules&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;lib&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;esm&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;cjs&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;lib/**/*&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;esm/**/*&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;cjs/**/*&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-string">&quot;scripts/**/*&quot;</span><br>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;compilerOptions&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span><br>    <span class="hljs-attr">&quot;target&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;ES2015&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;lib&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">&quot;DOM&quot;</span><span class="hljs-punctuation">,</span> <span class="hljs-string">&quot;ESNext&quot;</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;module&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;ESNext&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;moduleResolution&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Node&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;jsx&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;react&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;resolveJsonModule&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;esModuleInterop&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;skipLibCheck&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;noEmitOnError&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;baseUrl&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;.&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;rootDir&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;src&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;outDir&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;lib&quot;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;declaration&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;declarationMap&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span><br>    <span class="hljs-attr">&quot;paths&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span><span class="hljs-punctuation">&#125;</span><br>  <span class="hljs-punctuation">&#125;</span><br><span class="hljs-punctuation">&#125;</span><br></code></pre></td></tr></table></div></figure></li>
<li>package.json文件<figure class="highlight llvm"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-rmjw5vlacl5vox"></i><span>llvm</span><div class="collapse show" id="collapse-rmjw5vlacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs llvm">pnpm --<span class="hljs-keyword">filter</span> <span class="hljs-title">@study</span>/util <span class="hljs-keyword">add</span> react --save-peer<br>pnpm --<span class="hljs-keyword">filter</span> <span class="hljs-title">@study</span>/util <span class="hljs-keyword">add</span> rc-util -P -w<br>pnpm --<span class="hljs-keyword">filter</span> <span class="hljs-title">@study</span>/util <span class="hljs-keyword">add</span> <span class="hljs-title">@types</span>/node <span class="hljs-title">@types</span>/react  <span class="hljs-title">@types</span>/react-dom -D -w<br></code></pre></td></tr></table></div></figure>
改变main字段和module字段<figure class="highlight perl"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-h4o1milacl5vox"></i><span>perl</span><div class="collapse show" id="collapse-h4o1milacl5vox"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><code class="hljs perl">&#123;<br>	<span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;@study/util&quot;</span>,<br>	<span class="hljs-string">&quot;version&quot;</span>: <span class="hljs-string">&quot;1.0.0&quot;</span>,<br>	<span class="hljs-string">&quot;module&quot;</span>: <span class="hljs-string">&quot;esm/index.js&quot;</span>,<br>	<span class="hljs-string">&quot;main&quot;</span>: <span class="hljs-string">&quot;cjs/index.js&quot;</span>,<br>	<span class="hljs-string">&quot;typings&quot;</span>: <span class="hljs-string">&quot;lib/index.d.ts&quot;</span>,<br>	<span class="hljs-string">&quot;scripts&quot;</span>: &#123;<br>		<span class="hljs-string">&quot;build&quot;</span>: <span class="hljs-string">&quot;node ./scripts/build&quot;</span><br>	&#125;,<br>	<span class="hljs-string">&quot;dependencies&quot;</span>: &#123;<br>		<span class="hljs-string">&quot;rc-util&quot;</span>: <span class="hljs-string">&quot;^5.21.4&quot;</span><br>	&#125;,<br>	<span class="hljs-string">&quot;devDependencies&quot;</span>: &#123;<br>		<span class="hljs-string">&quot;@types/node&quot;</span>: <span class="hljs-string">&quot;^17.0.36&quot;</span>,<br>		<span class="hljs-string">&quot;@types/react&quot;</span>: <span class="hljs-string">&quot;^18.0.9&quot;</span>,<br>		<span class="hljs-string">&quot;@types/react-dom&quot;</span>: <span class="hljs-string">&quot;^18.0.5&quot;</span>,<br>		<span class="hljs-string">&quot;react&quot;</span>: <span class="hljs-string">&quot;^18.1.0&quot;</span><br>	&#125;,<br>	<span class="hljs-string">&quot;peerDependencies&quot;</span>: &#123;<br>		<span class="hljs-string">&quot;react&quot;</span>: <span class="hljs-string">&quot;^18.1.0&quot;</span><br>	&#125;<br>&#125;<br></code></pre></td></tr></table></div></figure></li>
<li>scripts文件夹下对ts文件进行编译生产cjs和esm两个文件夹</li>
<li>运行命令<code>pnpm --filter @study/util run build</code><br><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/front-end-dngineering/2022-11-06-22-09-51_3138b0a6.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-11-06-22-09-51"></li>
</ol>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E7%BB%84%E4%BB%B6%E5%BA%93/" class="category-chain-item">组件库</a>
  
  
    <span>></span>
    
  <a href="/categories/%E7%BB%84%E4%BB%B6%E5%BA%93/antd/" class="category-chain-item">antd</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E7%BB%84%E4%BB%B6%E5%BA%93/">#组件库</a>
      
        <a href="/tags/antd/">#antd</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>antd组件库搭建</div>
      <div>http://81.68.132.127/2022/11/11/FrontEndEngineering/组件库搭建/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Ikki</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年11月11日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2022年11月11日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/11/11/formily/formily%E7%AE%80%E7%89%88%E6%BA%90%E7%A0%81/" title="formily简版源码">
                        <span class="hidden-mobile">formily简版源码</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  <article id="comments" lazyload>
    
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"6KzYWc2oaEBaHgNl4UIicMJC-gzGzoHsz","appKey":"vJ4FIwKeHRmHraCJraAsjyZ7","path":"window.location.pathname","placeholder":"请输入你的评论\n昵称为必填项目(输入QQ号码可以自动获取昵称和邮箱)\n虽然email不是必选，但是填写了email可以收到推送通知哦！","avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":true,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":true},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


  </article>


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
      IKKI-专业BUG开发
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="/fluid/js/star.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
